<?php
namespace app\tp\controller;
// use think\config;
use think\Request;
use think\Db;

use think\Controller;     //这两个同时出现

class Index11  extends Controller  //这两个同时出现 //这两个同时出现
{
    public function index()
    {
       //  echo'http://mall.tjlyas.com/';
       // $where = null;
       $type = input('get.type',null);
       $name = input('get.name',null);
       if($type != null){$where[$type] = $name;}else{$where = null;}
       dump($where);
      // $where = input('get.where',null);
       $count=$this->select2($where);
       dump($count);
       echo Db::getlastsql();
       $limit = 8;
       //ceil 向上取整 例6.1 = 7
       $pages = ceil($count/$limit)+1;
        
     
       $page = 0;
       $data = $this->select1($where,$page,$limit);
      //  
      //  dump($data);
        $this->assign('pages',$pages);
       $this->assign('data',$data);
       $this->assign('type',$type);
       $this->assign('name',$name);
       return $this->fetch();
    }

    public function index2(){
        $type = input('get.type',null);
        $name = input('get.name',null);
        if($type != null){$where[$type] = $name;}else{$where = null;}
        $page = input('get.page',1,'intval');
       // $where = input('get.where',null);  
       
        $count=$this->select2($where);
       
        $limit = 8;
        $pages = ceil($count/$limit)+1;
        $data = $this->select1($where,$page,$limit);
        // echo Db::getlastsql(); 
        //  dump($data);
          $this->assign('pages',$pages);
         $this->assign('data',$data);
         $this->assign('type',$type);
         $this->assign('name',$name);
         return $this->fetch("index");
    }

    public function index3(){
        $type = input('post.superior',1,'intval');
        $name = input('post.name');
       // echo $superior."&".$name;
       if($type == "0"){$type = "content";$where['content'] = $name;}
       if($type == "1"){$type = "superior";$where['superior'] = $name;}
       if($type == "2"){$type = "spec";$where['spec'] = $name;}
       if($type == "3"){$type = "facturing";$where['facturing'] = $name;}
       $count = $this->select2($where);
       $limit = 8;
       $page = 1;
       $pages = ceil($count/$limit)+1;
       $this->assign('pages',$pages);
       $data = $this->select1($where,$page,$limit);
       $empty = "<div class='alert alert-danger'>没有找到您要查询的项目</div>";
                        
		$this->assign('empty',$empty);
      //  dump($data);
       $this->assign('data',$data);
       $this->assign('name',$name);
       $this->assign('type',$type);
       return $this->fetch("index");
    }

/****************************************************************************model********************************************************************************* */
protected function  select1($where,$page,$limit){

    return Db::table("note_listt")->where($where)->page($page)->limit($limit)->select();
}


protected function  select2($where){

    return Db::table("note_listt")->where($where)->count();
}


}